import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

export default defineNuxtPlugin((nuxtApp) => {
    // 配置 NProgress
    NProgress.configure({
        showSpinner: false,
        minimum: 0.1,
        easing: 'ease',
        speed: 400
    })

    // 添加 app:mounted 钩子，处理初始加载
    nuxtApp.hooks.hook('app:mounted', () => {
        NProgress.done()
    })

    // 添加 app:beforeMount 钩子，处理刷新开始
    nuxtApp.hooks.hook('app:beforeMount', () => {
        NProgress.start()
    })

    // 路由变化
    nuxtApp.hooks.hook('page:start', () => {
        NProgress.start()
    })

    nuxtApp.hooks.hook('page:finish', () => {
        NProgress.done()
    })
}) 